package o;

import android.content.Context;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.net.Uri;
import com.huawei.appgallery.common.media.api.OriginalMediaBean;
import java.util.ArrayList;

public final class bll {
    private static bll ˎ;

    private bll() {
    }

    public static synchronized bll ॱ() {
        bll o_bll;
        synchronized (bll.class) {
            if (ˎ == null) {
                ˎ = new bll();
            }
            o_bll = ˎ;
        }
        return o_bll;
    }

    public ArrayList<OriginalMediaBean> ˋ(Context context, Uri uri, String[] strArr, String str, String[] strArr2, String str2, String str3) {
        Cursor query;
        Throwable e;
        ArrayList<OriginalMediaBean> arrayList = new ArrayList();
        try {
            query = context.getContentResolver().query(uri, strArr, str, strArr2, str2);
            if (query != null) {
                while (query.moveToNext()) {
                    try {
                        OriginalMediaBean originalMediaBean = new OriginalMediaBean();
                        originalMediaBean.ˋ(query);
                        if (originalMediaBean.ˊ() % 180 != 0) {
                            int ˎ = originalMediaBean.ˎ();
                            originalMediaBean.ॱ(originalMediaBean.ॱ());
                            originalMediaBean.ˊ(ˎ);
                        }
                        if ("image".equals(str3) && (originalMediaBean.ˎ() == 0 || originalMediaBean.ॱ() == 0)) {
                            blf.ˋ.ˏ("ThumbnailDbHelper", "query , find error width height img.");
                            ˎ(originalMediaBean);
                        }
                        arrayList.add(originalMediaBean);
                    } catch (Exception e2) {
                        e = e2;
                    }
                }
            }
            if (query != null) {
                try {
                    query.close();
                } catch (Throwable e3) {
                    blf.ˋ.ˊ("ThumbnailDbHelper", "query Exception", e3);
                }
            }
        } catch (Exception e4) {
            e3 = e4;
            query = null;
            try {
                blf.ˋ.ˊ("ThumbnailDbHelper", "query Exception", e3);
                if (query != null) {
                    try {
                        query.close();
                    } catch (Throwable e32) {
                        blf.ˋ.ˊ("ThumbnailDbHelper", "query Exception", e32);
                    }
                }
                return arrayList;
            } catch (Throwable th) {
                e32 = th;
                if (query != null) {
                    try {
                        query.close();
                    } catch (Throwable e5) {
                        blf.ˋ.ˊ("ThumbnailDbHelper", "query Exception", e5);
                    }
                }
                throw e32;
            }
        } catch (Throwable th2) {
            e32 = th2;
            query = null;
            if (query != null) {
                query.close();
            }
            throw e32;
        }
        return arrayList;
    }

    private void ˎ(OriginalMediaBean originalMediaBean) {
        if (dof.ˋ(originalMediaBean.ʽ())) {
            blf.ˋ.ˏ("ThumbnailDbHelper", "initImageWidthAndHeight bead data empty");
            return;
        }
        Options options = new Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(originalMediaBean.ʽ(), options);
        originalMediaBean.ॱ(options.outWidth);
        originalMediaBean.ˊ(options.outHeight);
        blf.ˋ.ˎ("ThumbnailDbHelper", "initImageWidthAndHeight :  ; width:" + originalMediaBean.ˎ() + " ; height:" + originalMediaBean.ॱ());
    }
}
